<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>route</title>
    <script src="../lib/angularjs/angular.min.js"></script>
    <script src="../lib/angularjs/angular-route.min.js"></script>
    <script src="../lib/angularjs/angular-animate.min.js"></script>
</head>

<body>
<div ng-app="myApp">
    <header>
        <h1>Header</h1>
        <a href="#/">主界面</a>
        <a href="#/login">登录</a>
        <a href="#/dashboard">仪表盘</a>
        {{loginInfo}}
    </header>
    <div class="content">
        <div ng-view></div>
    </div>
    <footer>
        <h5>Footer</h5>
    </footer>
</div>
</body>
</html>
<script type="text/javascript">
    var app = angular.module("myApp", ["ngRoute"]);
    app.run(function ($rootScope) {
        $rootScope.loginInfo="请未登录";
    });
    app.config(['$routeProvider', function($routeProvider) {
        $routeProvider
            .when('/', {
                templateUrl: 'templeage-home.html',
                controller: 'HomeController'
            })
            .when('/login', {
                templateUrl: 'templeage-login.html',
                controller: 'LoginController'
            })
            .when('/dashboard', {
                templateUrl: 'templeage-other.html',
                controller: 'DashboardController',
                resolve: {
                    user: function(SessionService) {
                        console.log(SessionService.getCurrentUser())
                        return SessionService.getCurrentUser();
                    }
                }
            })
            .otherwise({
                redirectTo: '/'
            });
    }]);
    app.controller('DashboardController',function ($scope) {
        $scope.loginInfo="未登录";
    });
</script>